GtkScale: Move marks inward
authorMatthias Clasen <mclasen@redhat.com>
Thu, 4 Jun 2015 23:58:40 +0000 (19:58 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 4 Jun 2015 23:58:40 +0000 (19:58 -0400)
We don't want scale marks to affect scale sizing and positioning,
so draw them inside the range recangle. This avoids size changes
for marks that don't have labels, at least.

https://bugzilla.gnome.org/show_bug.cgi?id=749650

gtk/gtkscale.c

index f9f228ed946029bd2af0ae9953426f49a302fe2c..ee7f80435e7ddc0da2f73ee112b50a6cc2b07176 100644 (file)
@@ -1127,11 +1127,6 @@ gtk_scale_draw (GtkWidget *widget,
                         "value-spacing", &value_spacing,
                         NULL);
 
-  /* We need to chain up _first_ so the various geometry members of
-   * GtkRange struct are updated.
-   */
-  GTK_WIDGET_CLASS (gtk_scale_parent_class)->draw (widget, cr);
-
   if (priv->marks)
     {
       GtkOrientation orientation;
@@ -1161,15 +1156,15 @@ gtk_scale_draw (GtkWidget *widget,
               x1 = marks[i];
               if (mark->position == GTK_POS_TOP)
                 {
-                  y1 = range_rect.y;
-                  y2 = y1 - slider_width / 4;
+                  y1 = range_rect.y + slider_width / 4;
+                  y2 = range_rect.y;
                   min_pos = min_pos_before;
                   max_pos = find_next_pos (widget, m, marks + i, GTK_POS_TOP) - min_sep;
                 }
               else
                 {
-                  y1 = range_rect.y + range_rect.height;
-                  y2 = y1 + slider_width / 4;
+                  y1 = range_rect.y + range_rect.height - slider_width / 4;
+                  y2 = range_rect.y + range_rect.height;
                   min_pos = min_pos_after;
                   max_pos = find_next_pos (widget, m, marks + i, GTK_POS_BOTTOM) - min_sep;
                 }
@@ -1213,15 +1208,15 @@ gtk_scale_draw (GtkWidget *widget,
             {
               if (mark->position == GTK_POS_TOP)
                 {
-                  x1 = range_rect.x;
-                  x2 = range_rect.x - slider_width / 4;
+                  x1 = range_rect.x + slider_width / 4;
+                  x2 = range_rect.x;
                   min_pos = min_pos_before;
                   max_pos = find_next_pos (widget, m, marks + i, GTK_POS_TOP) - min_sep;
                 }
               else
                 {
-                  x1 = range_rect.x + range_rect.width;
-                  x2 = range_rect.x + range_rect.width + slider_width / 4;
+                  x1 = range_rect.x + range_rect.width - slider_width / 4;
+                  x2 = range_rect.x + range_rect.width;
                   min_pos = min_pos_after;
                   max_pos = find_next_pos (widget, m, marks + i, GTK_POS_BOTTOM) - min_sep;
                 }
@@ -1268,6 +1263,8 @@ gtk_scale_draw (GtkWidget *widget,
       g_free (marks);
     }
 
+  GTK_WIDGET_CLASS (gtk_scale_parent_class)->draw (widget, cr);
+
   if (priv->draw_value)
     {
       GtkAllocation allocation;